from datetime import datetime
import tkinter as tk
from gui.config import *
from tkinter.ttk import Separator


def head_handle(master, name:str):
    bg = '#c1cbd7'
    head = tk.Frame(master, bg=bg)
    staff_info = tk.Frame(head, bg=bg)
    li = name.split('_')
    if len(li) > 1:
        text = '工  号: ' + li[1]
    else:
        text = '工  号: ' + 'admin'
    tk.Label(staff_info, text=text, font=myFont, bg=bg).pack(side='top', anchor='nw', padx=(10, 0), pady=(5, 0))
    text = '操作员: ' + li[0]
    tk.Label(staff_info, text=text, font=myFont, bg=bg).pack(side='top', anchor='nw', padx=(10, 0), pady=(0, 5))
    staff_info.pack(side='left')

    nowTime = tk.StringVar()
    lb = tk.Label(head, textvariable=nowTime, font=myFont, bg=bg)

    def update_time():
        now = datetime.now()
        text = '时间：%s-%s-%s  %s:%s:%s' % \
               (
                   now.year,
                   '{:0>2d}'.format(now.month),
                   '{:0>2d}'.format(now.day),
                   '{:0>2d}'.format(now.hour),
                   '{:0>2d}'.format(now.minute),
                   '{:0>2d}'.format(now.second)
               )
        nowTime.set(text)
        lb.after(1000, update_time)

    update_time()
    lb.pack(side='right', padx=(0, 20))
    head.pack(side='top', fill='x')
    # Separator(master, orient='horizontal').pack(fill='x')


def foot_info(master):
    # 脚注
    lab = tk.Label(master, bg='#c1cbd7', text='©️2021 宾馆董事会 保留所有解释权', font=('楷体', 12), fg='gray') \
        .pack(side='bottom', fill='x', padx=(0, 0), pady=(10, 10))

